package com.hr;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.espirit.EntityMapping;
import com.espirit.eap.ICheckModelDuplicateInfo;
import com.espirit.eap.annotation.DomainModel;
import com.espirit.eap.manager.Department;
import com.espirit.eap.sa.DepartmentAware;
import com.googlecode.cswish.model.Saas;

@Entity
@DomainModel
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@BatchSize(size=10)
public class SchedualDefine extends EntityMapping implements DepartmentAware, Serializable,ICheckModelDuplicateInfo, Saas {

	private static final long serialVersionUID = -492320413956492769L;

	private Integer sid;
	public Integer getSid() {
		return sid;
	}

	public void setSid(Integer sid) {
		this.sid = sid;
	}
	
	@ManyToOne(fetch=FetchType.LAZY)
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}
	
	
	public String getWeekNbrs() {
		return weekNbrs;
	}
	public void setWeekNbrs(String weekNbrs) {
		this.weekNbrs = weekNbrs;
	}
	
	public String getScope() {
		return scope;
	}
	public void setScope(String scope) {
		this.scope = scope;
	}
	
	@OneToMany(targetEntity = SchedualScope.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL, mappedBy = "parent")
	public List<SchedualScope> getSchedualScopes() {
		return schedualScopes;
	}
	public void setSchedualScopes(List<SchedualScope> schedualScopes) {
		this.schedualScopes = schedualScopes;
	}
	
	

	@Transient
	public String getDeptIds() {
		return deptIds;
	}
	public void setDeptIds(String deptIds) {
		this.deptIds = deptIds;
	}
	
	private Department department;
	private String weekNbrs;
	private String scope;
	private List<SchedualScope> schedualScopes;
	private String deptIds;
	
	
	private List<SchedualEmployeeScope> employeeScopes;

	private static final String[] properties = new String[]{"department"};
	@Override
	public String[] gatherProperties() {
		return properties;
	}
	
	@OneToMany(targetEntity = SchedualEmployeeScope.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL, mappedBy = "parent")
	public List<SchedualEmployeeScope> getEmployeeScopes() {
		return employeeScopes;
	}
	public void setEmployeeScopes(List<SchedualEmployeeScope> employeeScopes) {
		this.employeeScopes = employeeScopes;
	}
	
}
